<template>
     <!-- 输入框 -->
     <header class="header">
      <h1>小黑记事本</h1>
      <input @keyup.enter="handleAdd" placeholder="请输入任务" class="new-todo" v-model="todoname" />
      <button class="add" @click="handleAdd">添加任务</button>
    </header>

</template>

<script>
export default {
    data(){
        return {
            todoname:''
        }
    },
    methods:{
       handleAdd(){
        if(!this.todoname.trim()){
            return alert('内容不能为空!')
        }
            this.$emit('add',this.todoname)
            this.todoname = ''
       }
    }
}
</script>

<style>

</style>